
public class SoundScheduler {
    private static final Map<UUID, BukkitTask> tasks = new ConcurrentHashMap<>();
    
    public static void play(Player player, Sound sound) {
        stop(player); // 停止旧任务
        BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
            player.playSound(player.getLocation(), sound, 0.5f, 1.0f);
        }, 0, 40L); // 每2秒播放
        tasks.put(player.getUniqueId(), task);
    }
}